// 处理时间函数
export const formatTimes = (val) => {
  // console.log(val)
  const dateObj = new Date(val);
  const year = dateObj.getUTCFullYear();
  const month = ("0" + (dateObj.getUTCMonth() + 1)).slice(-2);
  const day = ("0" + dateObj.getUTCDate()).slice(-2);
  const hours = ("0" + dateObj.getUTCHours()).slice(-2);
  const minutes = ("0" + dateObj.getUTCMinutes()).slice(-2);
  const seconds = ("0" + dateObj.getUTCSeconds()).slice(-2);
  return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
};

// 北京时间：2021-11-18 22:14:24
/* 时间yyyy-MM-dd HH:mm:ss转为时间戳 */
export const timeToTimestamp = (time) => {
  let timestamp = Date.parse(new Date(time).toString());
  //timestamp = timestamp / 1000; //时间戳为13位需除1000，时间戳为13位的话不需除1000
  console.log(time + "的时间戳为：" + timestamp);
  return timestamp;
  //2021-11-18 22:14:24的时间戳为：1637244864707
};
